package com.sjy.ylxt.factory;

import com.sjy.ylxt.entity.domain.YlxtAdmin;
import com.sjy.ylxt.entity.domain.YlxtAppointments;
import com.sjy.ylxt.entity.domain.YlxtEscorts;
import com.sjy.ylxt.entity.domain.YlxtPatient;
import com.sjy.ylxt.entity.dto.AddAdminDTO;
import com.sjy.ylxt.entity.dto.AddAppointmentDTO;
import com.sjy.ylxt.entity.dto.AddEscortsDTO;
import com.sjy.ylxt.entity.dto.AddPatientDTO;

/**
 * @Author: 史俊颖
 * @CreateTime: 2024-12-12
 * @Description: 转换类
 */
public class O2O {


    public static YlxtAdmin AdminDtoToEntity(AddAdminDTO addAdminDTO) {
        if (addAdminDTO == null) {
            return null;
        }
        YlxtAdmin ylxtAdmin = new YlxtAdmin();
        ylxtAdmin.setAdminName(addAdminDTO.getAdminName());
        ylxtAdmin.setPhoneNumber(addAdminDTO.getPhoneNumber());
        ylxtAdmin.setPassWord(addAdminDTO.getPassWord());
        return ylxtAdmin;
    }

    public static YlxtAppointments AppointmentDTOToEntity(AddAppointmentDTO dto, YlxtAppointments appointments) {
        if (dto == null) {
            return null;
        }
        YlxtAppointments ylxtAppointments = new YlxtAppointments();
        ylxtAppointments.setPatientId(Integer.valueOf(dto.getPatientId()));
        ylxtAppointments.setCompanionId(Integer.valueOf(dto.getCompanionId()));
        ylxtAppointments.setAppointmentDate(dto.getAppointmentDate());
        ylxtAppointments.setAppointmentTime(dto.getAppointmentTime());
        return ylxtAppointments;
    }

    public static YlxtEscorts escortsToDomain(AddEscortsDTO dto) {
        if (dto == null) {
            return null;
        }
        YlxtEscorts ylxtEscorts = new YlxtEscorts();
        ylxtEscorts.setUserName(dto.getUserName());
        ylxtEscorts.setPassword(dto.getPassword());
        ylxtEscorts.setEmail(dto.getEmail());
        ylxtEscorts.setPhoneNumber(dto.getPhoneNumber());
        ylxtEscorts.setCompanionCertificate(dto.getCompanionCertificate());
        ylxtEscorts.setCompanionExperience(dto.getCompanionExperience());
        return ylxtEscorts;
    }

    public static YlxtPatient patientToDomain(AddPatientDTO dto) {
        if (dto == null) {
            return null;
        }
        YlxtPatient ylxtPatient = new YlxtPatient();
        ylxtPatient.setUserName(dto.getUserName());
        ylxtPatient.setPassword(dto.getPassword());
        ylxtPatient.setEmail(dto.getEmail());
        ylxtPatient.setPhoneNumber(dto.getPhoneNumber());
        return ylxtPatient;
    }
}
